﻿* Encoding: UTF-8.
**use with file called Figs23variables.sav

***vote preference 2020

FREQUENCIES VARIABLES=QVOTEA_w6  QVOTEA1_w6
QVOTEB_w6  QVOTEB1_w6.

if (QVOTEA_w6=1 or QVOTEB_w6=2) vote2020=1.
if (QVOTEA_w6=2 or QVOTEB_w6=1) vote2020=2.
if (QVOTEA_w6=3 or QVOTEB_w6=3) vote2020=9.
if (QVOTEA_w6=4 or QVOTEB_w6=4) vote2020=3.

value labels vote2020 1 'rep' 2 'dem' 3 'third party' 9 'not voting'.

***vote preference 2016

if (QVOTEA_w1=1 or QVOTEB_w1=2) vote2016=1.
if (QVOTEA_w1=2 or QVOTEB_w1=1) vote2016=2.
if (QVOTEA_w1=3 or QVOTEa_w1=4 or QVOTEB_w1=3 or QVOTEB_w1=4) vote2016=3.
if (QVOTEA_w1=5 or QVOTEB_w1=5) vote2016=9.

value labels vote2016 1 'rep' 2 'dem' 3 'third party'   9 'not voting'.

frequencies VARIABLES = vote2016 vote2020.

***2016/2020

if (vote2016=9) turnout2016=0.
if (vote2016 le 3) turnout2016=1.


if (vote2020=9) turnout2020=0.
if (vote2020 le 3) turnout2020=1.

****Creating change Direction variable with high=Biden direction

FREQUENCIES vars = vote2020 vote2016.

if (vote2016=2) demvote2016=1.
if (vote2016=1 or vote2016=3) demvote2016=0.
if (vote2020=2) demvote2020=1.
if (vote2020=1 or vote2020=3) demvote2020=0.


if (vote2016=1 and vote2020=1) chgdemvote=0.
if (vote2016=2 and vote2020=2) chgdemvote=0.


***if voted for Trump or 3 in 2016, then to Biden=1; if voted for Clinton or 3 in 2016, then Trump in 2020=-1. 

if ((vote2016=1 or vote2016=3) and vote2020=2) chgdemvote=1.
if ((vote2016=2 or vote2016=3) and vote2020=1) chgdemvote=-1.

FREQUENCIES vars = chgdemvote.

***Demvoteplusincludes new to 2020 voters; creating fixed effects DV where 1=dem vote, 0=rep or third party or non voter in 2016; Dem vote versus anythgin else

if (vote2016=2) demvoteplus2016=1.
if (vote2020=2) demvoteplus2020=1.

if (vote2016=1 or vote2016=3 or vote2016=9) demvoteplus2016=0.
if (vote2020=1 or vote2020=3 or vote2020=9) demvoteplus2020=0.

descriptives vars =demvoteplus2016 demvoteplus2020 demvote2016 demvote2020.

***change in demvote plus

if (demvoteplus2016=demvoteplus2020) chgdemvoteplus=0.

if (demvoteplus2016=1 and demvoteplus2020=0) chgdemvoteplus=-1.
if (demvoteplus2016=0 and demvoteplus2020=1) chgdemvoteplus=1.

FREQUENCIES vars = chgdemvoteplus chgdemvote.


***creating blackwhite only


**perceived disc items, high=more discrimination

missing values DIS1_W1  DIS3_W1 (77,98,99).
recode DIS1_W1 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_1.
recode DIS3_W1 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_1.
compute pdblackwhite_1=pdblacks_1-pdwhites_1.


missing values DIS1_W2  DIS3_W2 (77,98,99).
recode DIS1_W2 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_2.
recode DIS3_W2 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_2.
compute pdblackwhite_2=pdblacks_2-pdwhites_2.


missing values DIS1_W3  DIS3_W3 (77,98,99).
recode DIS1_W3 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_3.
recode DIS3_W3 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_3.
compute pdblackwhite_3=pdblacks_3-pdwhites_3.


missing values DIS1_W4  DIS3_W4 (77,98,99).
recode DIS1_W4 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_4.
recode DIS3_W4 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_4.
compute pdblackwhite_4=pdblacks_4-pdwhites_4.


missing values DIS1_W5  DIS3_W5 (77,98,99).
recode DIS1_W5 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_5.
recode DIS3_W5 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_5.
compute pdblackwhite_5=pdblacks_5-pdwhites_5.


missing values DIS1_W6  DIS3_W6 (77,98,99).
recode DIS1_W6 (1=5) (5=1) (4=2) (2=4) (3=3) into pdblacks_6.
recode DIS3_W6 (1=5) (5=1) (4=2) (2=4) (3=3) into pdwhites_6.
compute pdblackwhite_6=pdblacks_6-pdwhites_6.

compute chgpdblackwhite16= pdblackwhite_6- pdblackwhite_1.

**analyses for Figure 3


oneway chgpdblackwhite16 by chgdemvote
    / CONTRAST=1 -1 0 
    / CONTRAST=0 1 -1.
oneway chgpdblackwhite16 by chgdemvoteplus
    / CONTRAST=1 -1 0 
    / CONTRAST=0 1 -1.

**analyses for Figure 1 and 2, cross-sectional means

**by race by wave

do if (racethnicity_w1 ge 1).
if (racethnicity_w1=1) white_1=1.
if (racethnicity_w1=2) black_1=1.
if (racethnicity_w1 ge 2) POC_1=1.
recode white_1 black_1 POC_1 (missing=0).
end if.
freq vars = white_1 black_1 POC_1.

do if (racethnicity_w2 ge 1).
if (racethnicity_w2=1) white_2=1.
if (racethnicity_w2=2) black_2=1.
if (racethnicity_w2 ge 2) POC_2=1.
recode white_2 black_2 POC_2 (missing=0).
end if.
freq vars = white_2 black_2 POC_2.


do if (racethnicity_w3 ge 1).
if (racethnicity_w3=1) white_3=1.
if (racethnicity_w3=2) black_3=1.
if (racethnicity_w3 ge 2) POC_3=1.
recode white_3 black_3 POC_3 (missing=0).
end if.
freq vars = white_3 black_3 POC_3.


do if (racethnicity_w4 ge 1).
if (racethnicity_w4=1) white_4=1.
if (racethnicity_w4=2) black_4=1.
if (racethnicity_w4 ge 2) POC_4=1.
recode white_4 black_4 POC_4 (missing=0).
end if.
freq vars = white_4 black_4 POC_4.


do if (racethnicity_w5 ge 1).
if (racethnicity_w5=1) white_5=1.
if (racethnicity_w5=2) black_5=1.
if (racethnicity_w5 ge 2) POC_5=1.
recode white_5 black_5 POC_5 (missing=0).
end if.
freq vars = white_5 black_5 POC_5.


do if (racethnicity_w6 ge 1).
if (racethnicity_w6=1) white_6=1.
if (racethnicity_w6=2) black_6=1.
if (racethnicity_w6 ge 2) POC_6=1.
recode white_6 black_6 POC_6 (missing=0).
end if.
freq vars = white_6 black_6 POC_6.




**people of color only

temporary.
select if (poc_1=1).
DESCRIPTIVES vars =  pdblackwhite_1  /STATISTICS=mean semean.

temporary.
select if (poc_2=1).
DESCRIPTIVES vars =  pdblackwhite_2 /STATISTICS=mean semean.

temporary.
select if (poc_3=1).
DESCRIPTIVES vars =  pdblackwhite_3 /STATISTICS=mean semean.

temporary.
select if (poc_4=1).
DESCRIPTIVES vars =   pdblackwhite_4  /STATISTICS=mean semean.

temporary.
select if (poc_5=1).
DESCRIPTIVES vars =   pdblackwhite_5 /STATISTICS=mean semean.

temporary.
select if (poc_6=1).
DESCRIPTIVES vars =    pdblackwhite_6  /STATISTICS=mean semean.

** whites only


temporary.
select if (white_1=1).
DESCRIPTIVES vars =    pdblackwhite_1  /STATISTICS=mean semean.

temporary.
select if (white_2=1).
DESCRIPTIVES vars =   pdblackwhite_2  /STATISTICS=mean semean.

temporary.
select if (white_3=1).
DESCRIPTIVES vars =  pdblackwhite_3 /STATISTICS=mean semean.

temporary.
select if (white_4=1).
DESCRIPTIVES vars =   pdblackwhite_4 /STATISTICS=mean semean.

temporary.
select if (white_5=1).
DESCRIPTIVES vars = pdblackwhite_5 /STATISTICS=mean semean.

temporary.
select if (white_6=1).
DESCRIPTIVES vars =   pdblackwhite_6 /STATISTICS=mean semean.


** blacks only

temporary.
select if (black_1=1).
DESCRIPTIVES vars =    pdblackwhite_1  /STATISTICS=mean semean.

temporary.
select if (black_2=1).
DESCRIPTIVES vars =   pdblackwhite_2  /STATISTICS=mean semean.

temporary.
select if (black_3=1).
DESCRIPTIVES vars =   pdblackwhite_3  /STATISTICS=mean semean.

temporary.
select if (black_4=1).
DESCRIPTIVES vars =   pdblackwhite_4 /STATISTICS=mean semean.

temporary.
select if (black_5=1).
DESCRIPTIVES vars =   pdblackwhite_5 /STATISTICS=mean semean.

temporary.
select if (black_6=1).
DESCRIPTIVES vars =  pdblackwhite_6 /STATISTICS=mean semean.



**by party by wave

if (PARTYID5_W1 =3 or partyid5_w1=-1) indep_1=1.
if (PARTYID5_W1 =1 or PARTYID5_W1 =2) dem_1=1.
if (PARTYID5_W1 =4 or PARTYID5_W1 =5) rep_1=1.

if (PARTYID5_W1  ne 3 and partyid5_w1 ne -1) indep_1=0.
if (PARTYID5_W1  ne 1 and PARTYID5_W1 ne 2) dem_1=0.
if (PARTYID5_W1 ne 4 and PARTYID5_W1  ne 5) rep_1=0.

if (PARTYID5_W2 =3 or partyid5_w2=-1) indep_2=1.
if (PARTYID5_W2 =1 or PARTYID5_W2 =2) dem_2=1.
if (PARTYID5_W2 =4 or PARTYID5_W2 =5) rep_2=1.

if (PARTYID5_W2  ne 3 and partyid5_w2 ne -1) indep_2=0.
if (PARTYID5_W2  ne 1 and PARTYID5_W2 ne 2) dem_2=0.
if (PARTYID5_W2 ne 4 and PARTYID5_W2 ne 5) rep_2=0.


if (PARTYID5_W3 =3 or partyid5_w3=-1) indep_3=1.
if (PARTYID5_W3 =1 or PARTYID5_W3 =2) dem_3=1.
if (PARTYID5_W3 =4 or PARTYID5_W3 =5) rep_3=1.

if (PARTYID5_W3  ne 3 and partyid5_w3 ne -1) indep_3=0.
if (PARTYID5_W3  ne 1 and PARTYID5_W3 ne 2) dem_3=0.
if (PARTYID5_W3 ne 4 and PARTYID5_W3 ne 5) rep_3=0.


if (PARTYID5_W4 =3 or partyid5_w4=-1) indep_4=1.
if (PARTYID5_W4 =1 or PARTYID5_W4 =2) dem_4=1.
if (PARTYID5_W4 =4 or PARTYID5_W4 =5) rep_4=1.

if (PARTYID5_W4  ne 3 and partyid5_w4 ne -1) indep_4=0.
if (PARTYID5_W4  ne 1 and PARTYID5_W4 ne 2) dem_4=0.
if (PARTYID5_W4 ne 4 and PARTYID5_W4 ne 5) rep_4=0.


if (PARTYID5_W5 =3 or partyid5_w5=-1) indep_5=1.
if (PARTYID5_W5 =1 or PARTYID5_W5 =2) dem_5=1.
if (PARTYID5_W5 =4 or PARTYID5_W5 =5) rep_5=1.

if (PARTYID5_W5  ne 3 and partyid5_w5 ne -1) indep_5=0.
if (PARTYID5_W5  ne 1 and PARTYID5_W5 ne 2) dem_5=0.
if (PARTYID5_W5 ne 4 and PARTYID5_W5 ne 5) rep_5=0.


if (PARTYID5_W6 =3 or partyid5_w6=-1) indep_6=1.
if (PARTYID5_W6 =1 or PARTYID5_W6 =2) dem_6=1.
if (PARTYID5_W6 =4 or PARTYID5_W6 =5) rep_6=1.

if (PARTYID5_W6  ne 3 and partyid5_w6 ne -1) indep_6=0.
if (PARTYID5_W6  ne 1 and PARTYID5_W6 ne 2) dem_6=0.
if (PARTYID5_W6 ne 4 and PARTYID5_W6 ne 5) rep_6=0.


*wave 1

temporary.
select if (dem_1 ne 1 and rep_1 ne 1).
descriptives vars = pdblackwhite_1 /statistics=mean semean.

temporary.
select if (dem_1 eq 1).
descriptives vars = pdblackwhite_1 /statistics=mean semean.

temporary.
select if (rep_1 eq 1).
descriptives vars = pdblackwhite_1/statistics=mean semean.

**wave 2

temporary.
select if (dem_2 ne 1 and rep_2 ne 1).
descriptives vars = pdblackwhite_2 /statistics=mean semean.

temporary.
select if (dem_2 eq 1).
descriptives vars = pdblackwhite_2 /statistics=mean semean.

temporary.
select if (rep_2 eq 1).
descriptives vars = pdblackwhite_2/statistics=mean semean.


**wave 3

temporary.
select if (dem_3 ne 1 and rep_3 ne 1).
descriptives vars = pdblackwhite_3 /statistics=mean semean.

temporary.
select if (dem_3 eq 1).
descriptives vars = pdblackwhite_3 /statistics=mean semean.

temporary.
select if (rep_3 eq 1).
descriptives vars = pdblackwhite_3/statistics=mean semean.


**wave 4

temporary.
select if (dem_4 ne 1 and rep_4 ne 1).
descriptives vars = pdblackwhite_4 /statistics=mean semean.

temporary.
select if (dem_4 eq 1).
descriptives vars = pdblackwhite_4 /statistics=mean semean.

temporary.
select if (rep_4 eq 1).
descriptives vars = pdblackwhite_4/statistics=mean semean.


**wave 5

temporary.
select if (dem_5 ne 1 and rep_5 ne 1).
descriptives vars = pdblackwhite_5 /statistics=mean semean.

temporary.
select if (dem_5 eq 1).
descriptives vars = pdblackwhite_5 /statistics=mean semean.

temporary.
select if (rep_5 eq 1).
descriptives vars = pdblackwhite_5/statistics=mean semean.

**wave 6

temporary.
select if (dem_6 ne 1 and rep_6 ne 1).
descriptives vars = pdblackwhite_6 /statistics=mean semean.

temporary.
select if (dem_6 eq 1).
descriptives vars = pdblackwhite_6 /statistics=mean semean.

temporary.
select if (rep_6 eq 1).
descriptives vars = pdblackwhite_6/statistics=mean semean.

